package practice08;

public class Person {
    //写一个Person类，要有id，name，age属性，靠id来判断是否是同一个人。要有一个introduce方法，
    //introduce方法返回一个字符串形如：
    //>My name is Tom. I am 21 years old.

    String name;
    Integer age;
    Integer id;
    public Person(int id,String name, int age) {
        this.id=id;
        this.name=name;
        this.age=age;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || !getClass().equals(o.getClass())) {
            return false;
        }

        Person person = (Person) o;
        return id.equals(person.id);
    }
    @Override
    public int hashCode() {
        return id;
    }


    public String introduce() {
        return "My name is "+name+". I am "+age+" years old.";
    }
}
